yonicstudiosfandomcom_es-20200213-history
Módulo:Tnavbar
-- -- Implements and variants -- -- @todo move the hardcoded css to MediaWiki:Common.css given how many pages it's found on -- local p = {} local yesno = require( 'Module:Yesno' ) function p.navbar( frame ) local args = frame:getParent().args -- prevent errors on template page if not args1 then return end return p._navbar( args ) end function p._navbar( args ) local tag if yesno( args.nodiv ) then tag = mw.html.create( 'span' ) else tag = mw.html.create( 'div' ) :css( { 'background-color' = 'transparent', padding = '0' } ) end local tagStyle = args.style or '' local fontstyle = args.fontstyle or '' if args.fontstyle then tagStyle = tagStyle .. ';' .. args.fontstyle end if args.fontcolor then tagStyle = tagStyle .. ';color:' .. args.fontcolor fontstyle = fontstyle .. ';color:' .. args.fontcolor end tag :addClass( 'plainlinks' ) -- no idea what this class does :addClass( 'plainlinksneverexpand' ) :addClass( 'noprint' ) :css( { 'white-space' = 'nowrap', 'font-weight' = 'normal', 'font-size' = 'xx-small' } ) :cssText( tagStyle ) local prepText = '' -- we're checking if any of these have been set to 1 -- if not we add the prepText -- @todo find a better way of doing this if not ( yesno( args.mini ) or yesno( args.miniv ) or yesno( args.viewplain ) or yesno( args.plain ) ) then prepText = 'This box ' end local view, talk, edit = 'v', 'd', 'e' if yesno( args.viewplain ) or yesno( args.plain ) then view = 'view' talk = 'talk' edit = 'edit' end viewSpan = mw.html.create( 'span' ) :attr( 'title', 'Ver esta plantilla' ) :cssText( fontstyle ) :wikitext( view ) talkSpan = mw.html.create( 'span' ) :attr( 'title', 'Ver la página de discusión de esta plantilla' ) :cssText( fontstyle ) :wikitext( talk ) editSpan = mw.html.create( 'span' ) :attr( 'title', 'Puedes editar esta plantilla' ) :cssText( fontstyle ) :wikitext( edit ) local title = mw.text.trim( args1 ) local ns, titleTbl, page, talk if mw.ustring.sub( title, 1, 1 ) ':' then -- mainspace title = mw.ustring.sub( title, 2 ) page = title talk = 'Talk:' .. title elseif mw.ustring.match( title, ':' ) then -- split title to see if it has a valid namespace titleTbl = mw.text.split( title, ':' ) ns = mw.site.namespaces[titleTbl1] if ns ~= nil then page = ns.name .. ':' .. table.concat( titleTbl, '', 2 ) if ns.isTalk then talk = page else talk = ns.talk.name .. ':' .. table.concat( titleTbl, '', 2 ) end end end -- this happens if there's no semi-colons in title -- or if there is semi-colons but it didn't have valid ns name if not page then page = 'Template:' .. title talk = 'Template talk:' .. title end tag :wikitext( prepText ) :wikitext( '' .. tostring( viewSpan ) .. '' ) if not( yesno( args.miniv ) or yesno( args.viewplain ) ) then local frame = mw.getCurrentFrame() tag :wikitext( ' ' ) :tag( 'span' ) :css( 'font-size', '80%' ) :wikitext( '•' ) :done() :wikitext( ' ' ) :wikitext( '.. tostring( mw.uri.fullUrl( talk ) ) .. ' ' .. tostring( talkSpan ) .. '' ) :wikitext( ' ' ) :tag( 'span' ) :css( 'font-size', '80%' ) :wikitext( '•' ) :done() :wikitext( ' ' ) :wikitext( '.. tostring( mw.uri.fullUrl( page, 'action=edit' ) ) .. ' ' .. tostring( editSpan ) .. '' ) end tag = tostring( tag ) if yesno( args.nodiv ) then tag = tag .. ' ' end return tag end function p.collapsible( frame ) local args = frame:getParent().args return p._collapsible( args ) end function p._collapsible( args ) local nav_args = { 1 = args2, fontcolor = args.fontcolor } -- prevent errors on template page if not args2 then return end if yesno( args.plain ) then nav_args.plain = '1' else nav_args.mini = '1' end navbar = p._navbar( nav_args ) local div = mw.html.create( 'div' ) :css( { float = 'left', 'text-align' = 'left', width = '6em' } ) :wikitext( navbar ) local span = mw.html.create( 'span' ) :wikitext( args1 ) if args.fontcolor then span :css( 'color', fontcolor ) end return tostring( div ) .. tostring( span ) end return p